package com.mes.data.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.mes.common.core.utils.poi.ExcelUtil;
import com.mes.common.core.web.controller.BaseController;
import com.mes.common.core.web.domain.AjaxResult;
import com.mes.common.core.web.page.TableDataInfo;
import com.mes.common.log.annotation.Log;
import com.mes.common.log.enums.BusinessType;
import com.mes.common.security.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mes.data.domain.DataReportDetail;
import com.mes.data.service.IDataReportDetailService;

/**
 * 数据分析报告明细Controller
 * 
 * @author itflash
 * @date 2025-02-27
 */
@RestController
@RequestMapping("/data/reportDetail")
public class DataReportDetailController extends BaseController
{
    @Autowired
    private IDataReportDetailService dataReportDetailService;

    /**
     * 查询数据分析报告明细列表
     */
    @RequiresPermissions("data:reportDetail:list")
    @GetMapping("/list")
    public TableDataInfo list(DataReportDetail dataReportDetail)
    {
        startPage();
        List<DataReportDetail> list = dataReportDetailService.selectDataReportDetailList(dataReportDetail);
        return getDataTable(list);
    }

    /**
     * 导出数据分析报告明细列表
     */
    @RequiresPermissions("data:reportDetail:export")
    @Log(title = "数据分析报告明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DataReportDetail dataReportDetail)
    {
        List<DataReportDetail> list = dataReportDetailService.selectDataReportDetailList(dataReportDetail);
        ExcelUtil<DataReportDetail> util = new ExcelUtil<DataReportDetail>(DataReportDetail.class);
        util.exportExcel(response, list, "数据分析报告明细数据");
    }

    /**
     * 获取数据分析报告明细详细信息
     */
    @RequiresPermissions("data:reportDetail:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dataReportDetailService.selectDataReportDetailById(id));
    }

    /**
     * 新增数据分析报告明细
     */
    @RequiresPermissions("data:reportDetail:add")
    @Log(title = "数据分析报告明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DataReportDetail dataReportDetail)
    {
        return toAjax(dataReportDetailService.insertDataReportDetail(dataReportDetail));
    }

    /**
     * 修改数据分析报告明细
     */
    @RequiresPermissions("data:reportDetail:edit")
    @Log(title = "数据分析报告明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DataReportDetail dataReportDetail)
    {
        return toAjax(dataReportDetailService.updateDataReportDetail(dataReportDetail));
    }

    /**
     * 删除数据分析报告明细
     */
    @RequiresPermissions("data:reportDetail:remove")
    @Log(title = "数据分析报告明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dataReportDetailService.deleteDataReportDetailByIds(ids));
    }
}
